<?php
/**
 *
 * User: JSparrow
 * DateTime: 2016/12/16 16:58
 * Created by PhpStorm.
 */

namespace app\modules\admin\components;


class DbManager extends \yii\rbac\DbManager
{
	/**
	 * Memory cache of assignments
	 * @var array
	 */
	private $_assignments = [];
	private $_childrenList;

	/**
	 * @inheritdoc
	 */
	public function getAssignments($userId)
	{
		if (!isset($this->_assignments[$userId])) {
			$this->_assignments[$userId] = parent::getAssignments($userId);
		}
		return $this->_assignments[$userId];
	}

	/**
	 * @inheritdoc
	 */
	protected function getChildrenList()
	{
		if ($this->_childrenList === null) {
			$this->_childrenList = parent::getChildrenList();
		}
		return $this->_childrenList;
	}
}